
module TestCompiler where
import Text.Printf
import LanguageCompilerCommon
import System

headText = "module %s where\n\
\import Synchronizers\n\
\import System\n\
\import SynchronizerTest\n\
\import Test.HUnit((~:))\n\
\mainSync = _main "

--invoked by: runHaskell TestCompiler sourceFile moduleName targetFile
main = do
    files <- getArgs
    let fileName = head files
    source <- readFile fileName
    let header = printf headText (files !! 1)
    case compileStringWithHeader header source of
            Left msg -> putStrLn msg
            Right code -> writeFile (files !! 2) (code "")
